//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGITTARIUS_ASSERT_H_
#define __SAGITTARIUS_ASSERT_H_

//== INCLUDES ========================================================================

#include "SagittariusCommon.h"
#include <assert.h>

#ifdef __cplusplus
namespace Sagittarius
{
#endif
    //We have many styles to choose from...
    #define SAGITTARIUS_ASSERT1( x ) assert( x )
    #define SAGITTARIUS_ASSERT2( x, msg ) assert( (x) && msg ) //thank you gcc
    #define SAGITTARIUS_IASSERT1( x ) assert( !(x) )
    #define SAGITTARIUS_IASSERT2( x, msg ) assert( !(x) && msg )
    #define EXPAND(x) x //Workaround for MSVC bug
    #define GET_ASTM(A1, A2, A3, A4, ...) A4
    
    #define SAGITTARIUS_ASSERT( ... ) EXPAND(GET_ASTM(__VA_ARGS__, ***error*** "Too many arguments to assert; file: "__FILE__:__LINE__,\
        SAGITTARIUS_ASSERT2, SAGITTARIUS_ASSERT1)( __VA_ARGS__ ))
    
    //Shorthand:
    #define AST( ... ) SAGITTARIUS_ASSERT( __VA_ARGS__ )
    //Assert true
    #define AT( ... ) SAGITTARIUS_ASSERT( __VA_ARGS__ )
    //Assert not zero:
    #define AN( ... ) SAGITTARIUS_ASSERT( __VA_ARGS__ )
    //Assert ^ZERO^:
    #define AZ( ... ) EXPAND(GET_ASTM(__VA_ARGS__, ***error*** "Too many arguments to assert; file: "__FILE__:__LINE__,\
        SAGITTARIUS_IASSERT2, SAGITTARIUS_IASSERT1)( __VA_ARGS__ ))
#ifdef __cplusplus
} //namespace Sagittarius
#endif

#endif
